"""
列表元素个数的加权和(1)
"""
def judge(l, c):
    result = 0
    if type(l) == list:
        for i in l:
            result += judge(i, c+1)
    elif type(l) == tuple:
        for i in l:
            result += judge(i, c+1)
    elif type(l) == int:
        result += c
    return result
list1 = list(eval(input()))
sum1 = 0
for i in list1:
    sum1 += judge(i, 1)
print(sum1)